# -*- coding: utf-8 -*-
# @Author: Zach-Pineappleman
# @E-mail: 354399824@qq.com
# @Date:   2025-03-13 20:59:51
# @File_name:utils.py
# @Last Modified by:   Zach-Pineappleman
# @Last Modified time: 2025-03-13 21:10:37

# utils.py
# 包含通用工具函数，如行为类型提取、日志配置等。
import logging
import re
from datetime import datetime

def setup_logging(log_file):
    logging.basicConfig(
        filename=log_file,
        level=logging.INFO,
        format='%(asctime)s - %(message)s',
        datefmt='%Y-%m-%d %H:%M:%S'
    )

def extract_behavior_type(analysis_text):
    pattern = r'(\d+)\s*[.、:]?\s*(认真专注工作|吃东西|用杯子喝水|喝饮料|玩手机|睡觉|其他)'
    match = re.search(pattern, analysis_text)
    if match:
        return match.group(1), match.group(2)
    return "0", "未识别"